<template>
    <div id="FairList">
        <el-dialog :close-on-click-modal="false" :show-close="false" width="900px"
                   :visible.sync="show">
            <vj-table ref="multipleTable" :pagination="false" @selection-change="selections=$event"
                      show-checkbox :page-obj="pageObj" @loadTable="onSearch" :loading="loading" :cfg-list="cfgList"
                      :table-data="tableData"/>
            <footer slot="footer">
                <el-button type="primary" @click="onSubmit">确定</el-button>
            </footer>
        </el-dialog>
    </div>
</template>
<script lang="ts">
    import Vue, {ComponentOptions, VueConstructor} from "vue"
    import Component from 'vue-class-component'
    import BodyContainer from "@/components/layout/body-container.vue";
    import SearchFormContainer from "@/components/layout/search-form-conatiner.vue";
    import {Mixins, PropSync, Ref} from "vue-property-decorator";
    import {TableMixin} from "@/plugins/mixins/table";
    import {requestByGet, requestByPost} from "@/utils/request";
    import {formatOptions, groupBy, hookLoading, itemFromArr, updateCfgOption} from "vijay-util";
    import TextButton from "@/components/basic/text-button.vue";
    import {CompanyDeliveryTB, CompanyFairTB, CompanyJobTB, CompanyTB, PuzzleRecordTB, UserTB} from "@/config/table";
    import UserDialog from "@/components/dialog/user-dialog.vue";
    import CompanyDialog from "@/components/dialog/company/company-dialog.vue";
    import CompanyAddDialog from "@/components/dialog/company/company-add-dialog.vue";
    import CompanyTableDialog from "@/components/dialog/company/company-table-dialog.vue";

    export const title = "user";
    @Component({
        components: {
            CompanyTableDialog,
            CompanyAddDialog, CompanyDialog, UserDialog, TextButton, SearchFormContainer, BodyContainer
        }
    })
    export default class FairList extends Mixins(TableMixin) implements ComponentOptions<Vue> {
        name = "FairList"
        show = false
        cfgList = CompanyFairTB;
        selections: any[] = [];
        @Ref() multipleTable!: any;
        @hookLoading()
        async onSearch(pageNo?, pageSize?) {
            const params = Object.assign({pageNo: 1, pageSize: 999}, this.searchForm);
            const res = await requestByGet(`qqc/qqcRecjob/list`, params);
            this.tableData = res.records;
            return res;
        }
        onSubmit() {
            this.show = false;
            let companies = this.selections.map(({qqcJobtitleList}) => qqcJobtitleList).flat(Infinity);
            companies = companies.filter(({id}, idx) => !companies.slice(idx).find(({id: oid}) => oid === id))
            this.$emit('submit', companies)
        }
        open() {
            this.show = true;
        }
        created() {
            this.onSearch();
        }
    }
</script>

<style scoped lang="scss">
    @import "~assets/common.scss";
    @import "~assets/scss/variables.scss";
    #FairList {
    }
</style>
